package com.cn.zpark;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: JdbcGetConnection
 * @Description:获取连接
 * @author: RZS
 * @date: 2022/3/30  9:34
 */
public class JdbcGetConnection {
    public static void main(String[] args) {
        /*
            获取连接的步骤：
                1、注册驱动
                2、获取连接对象
         */
        String url = "jdbc:mysql://localhost:3306/mysql?useSSL=false&serverTimezone=UTC&characterEncoding=UTF-8";
        String user = "root";
        String pwd = "root";
        try {
            // 、注册驱动
            Class.forName("com.mysql.jdbc.Driver");
            // 2、获取连接对象
            Connection conn = DriverManager.getConnection(url, user, pwd);
            System.out.println(conn);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
